package com.wmm.fast.main.shop2Observer.eventBus;

/**
 * @Auther: wangzun
 * @Date: 2018/9/13 11:40
 * @Description:事件委托执行m,与单纯的观察者模式相比优点是没有限制死的观察者类型, 可以通知任意对象执行任意方法.传递任意参数,可以是毫不相关的对象
 */
public class EventBusExecutor {
    public static void main(String[] args) {
        Notifyler notifyler = new DefaultNotifier();

        ArmyMan general = new GeneralHandler("女魔头","CIA头头");
        ArmyMan soldier = new SoldierHandler("Eason Hunt","IMF头头");

        //CIA眉头一皱发现事情不对
        Order order = new Order("Syndicate wanna to destroy the world");
        //委托中间人发送消息至IMF.

        notifyler.addListener(general,"publishOrder",order.getTheOrder());
        notifyler.addListener(soldier,"executeOrder",order.getTheOrder() + "!!!,must to Stop them");
        notifyler.notifyEAll();


    }
}
